<extend name="Public/base" />
<block name="style">
    <style>
        .xuanzhuan{
        transform:rotate(180deg);
        -ms-transform:rotate(180deg); /* Internet Explorer */
        -moz-transform:rotate(180deg); /* Firefox */
        -webkit-transform:rotate(180deg); /* Safari 和 Chrome */
        -o-transform:rotate(180deg);
        }
    </style>
</block>
<block name="body">
    <form method="POST" id="list" action="{:U('warnExport')}">

    <!-- 标题栏 -->
    <div class="main-title">
        <h2>{$title}</h2>
    </div>
    <div class="cf">
        <div class="search-form fr cf">

            <div class="sleft">
                <select type="text" name="status" class="search-input input-sm input"  style="height:28px;">
                    <option value="">--全部状态--</option>
                    <option value=1 {$status==1?'selected':''}>库存不足</option>
                    <option value=2 {$status==2?'selected':''}>库存偏低</option>
                    <option value=3 {$status==3?'selected':''}>库存正常</option>
                    <option value=4 {$status==4?'selected':''}>库存过高</option>
                </select>
            </div>
            <div class="sleft" >
                <input type="text"  name="pname" class=" search-input input" value="{:I('pname')}" placeholder="商品名称" style="height:28px;" />
            </div>
            <div class="sleft">
                <input type="text"  name="BIN" class=" search-input input" value="{:I('BIN')}" placeholder="商品编码" />
                <a class="sch-btn" href="javascript:;" id="search" url="{:U('cntwarn')}"><i class="btn-search"></i></a>
            </div>
        </div>
    </div>
    </form>

    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table id="inventoryTable">
                <thead>
                    <tr>
                        <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                        <th>BIN</th>
                        <th>商品名</th>
                        <th>规格</th>
                        <th>库存</th>
                        <th>状态</th>
                        <th style="width: 30%">
                            <eq name="UID" value = "1"></eq>
                            状态范围图
                        </th>
                        <!--<th>榨汁期</th>-->
                        <!--<th>待处理</th>-->
                    </tr>
                </thead>
                <tbody>
                        <volist name="_list" id="vo">
                            <tr>
                                <td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
                                <td>{$vo.BIN} </td>
                                <td>{$vo.pname}</td>
                                <td>{$vo.BIN_array.spec}</td>
                                <td>{$vo.cnt}</td>
                                <td>
                                    <if condition="$vo['cnt'] elt $vo['BIN_array']['cnt_low']">
                                        <span class="btn btn-danger">库存不足</span>
                                    </if>
                                    <if condition="$vo['cnt'] gt $vo['BIN_array']['cnt_low'] &&$vo['cnt'] elt $vo['BIN_array']['cnt_poor']">
                                        <span class="btn btn-warning">库存偏低</span>
                                    </if>
                                    <if condition="$vo['cnt'] gt $vo['BIN_array']['cnt_poor'] &&$vo['cnt'] elt $vo['BIN_array']['cnt_much']">
                                        <span class="btn btn-success ">库存正常</span>
                                    </if>
                                    <if condition="$vo['cnt'] gt $vo['BIN_array']['cnt_much']">
                                        <span class="btn btn-info ">库存过高</span>
                                    </if>
                                </td>
                                <td>
                                    <div style="width: 100%;padding-left: <?php echo $vo['now_per'].'%';?>;">
                                        <div style="width:5px;padding: 0px;" class="xuanzhuan">▲</div>
                                    </div>
                                    <div class="progress progress-striped active" style="margin-bottom: 0px;" >
                                        <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:<?php echo $vo['low_per'].'%';?>">
                                            <span class="" style="float: right;font-size: xx-small">{$vo.BIN_array.cnt_low}</span>
                                        </div>
                                        <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:<?php echo $vo['poor_per'].'%';?>">
                                            <span class="" style="float: right;font-size: xx-small">{$vo.BIN_array.cnt_poor}</span>
                                         </div>
                                        <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width:<?php echo $vo['normal_per'].'%';?>">
                                            <span class="" style="float: right;font-size: xx-small">{$vo.BIN_array.cnt_much}</span>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </volist>
                </tbody>
        </table>
    </div>
    <div class="page">
        {$_page}
    </div>
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
            <form action="{:U('add_warn_days')}" method="post" class="form-horizontal">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="exampleModalLabel">修改贮存时间</h4>
                    </div>
                    <div class="modal-body" style="margin-left: 5px;">
                            <div class="form-group">
                                <input type="hidden" name="id" id="id">
                                <label for="recipient-name" class="control-label">输入更改天数:</label>
                                <input type="text" name="days" placeholder="正数延长，负数缩短" class="form-control" id="recipient-name">
                            </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default " data-dismiss="modal">取消</button>
                        <button type="submit" id="submit" class="btn btn-primary " >确认更改</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <script type="text/javascript">
//    $("#inventoryTable").DataTable({
//            searching:false,
//            language: {
//                search: "查询:",
//                lengthMenu:    "每页显示 _MENU_ 条",
//                info:           "当前  _START_ - _END_ 条，共 _TOTAL_ 条",
//                paginate: {
//                    first:      "第一页",
//                    previous:   "上一页",
//                    next:       "下一页",
//                    last:       "最后一页"
//                },
//            }
//        });
        //搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('.input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
    $(".add-days").click(function(){
        $('#id').val($(this).data('id'));
        $("#exampleModal").modal();
    });
    $('.confirm').click(function(){
        if(confirm("确认操作")){

        }else{
            return false;
        }
    });
        //导航高亮
    highlight_subnav('{:U('Inventory/cntwarn')}');
    </script>
</block>
